//
//  ShangPinPingJiaViewController.m
//  一键联IOS
//
//  Created by xufei on 15/12/28.
//  Copyright © 2015年 xufei. All rights reserved.
//

#import "ShangPinPingJiaViewController.h"
#import "WeiDianDingDanViewController.h"
@interface ShangPinPingJiaViewController ()

@end

@implementation ShangPinPingJiaViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIView*view=[[UIView alloc]initWithFrame:CGRectMake(0, 20, WIDE, 44)];
    view.backgroundColor=RGB_COLOR(0x00c49f);
    [self.view addSubview:view];
    UIButton*backBut=[[UIButton alloc]initWithFrame:CGRectMake(10,7,30,30)];
    [backBut setBackgroundImage:[UIImage imageNamed:@"返回箭头"] forState:UIControlStateNormal];
    [backBut addTarget:self action:@selector(backBut) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:backBut];
    UILabel*daoLabel=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/2-40, 7,80, 30)];
    daoLabel.text=@"评价订单";
    daoLabel.textAlignment=NSTextAlignmentCenter;
    daoLabel.textColor=[UIColor whiteColor];
    [view addSubview:daoLabel];
    view1=[[UIView alloc]initWithFrame:CGRectMake(0, 64+30, WIDE, 20)];
    [self.view addSubview:view1];
    for (int i=0; i<3; i++)
    {
        UIButton*pingJiaBut=[[UIButton alloc]initWithFrame:CGRectMake((WIDE-200)/6+((WIDE-60)/3+20)*i,0,20,20)];
        [pingJiaBut setBackgroundImage:[UIImage imageNamed:@"购物车未选择"] forState:UIControlStateNormal];
           [pingJiaBut setBackgroundImage:[UIImage imageNamed:@"购物车选中"] forState:UIControlStateSelected];
        pingJiaBut.tag=i;
        
        [pingJiaBut addTarget:self action:@selector(pingJiaBut:) forControlEvents:UIControlEventTouchUpInside];
        if (i==0)
        {
            _lastBtn = pingJiaBut;
            _lastBtn.selected=NO;
           // _selectBut=pingJiaBut.tag;
            
        }
        [view1 addSubview:pingJiaBut];
        UILabel*pingJiaLabel=[[UILabel alloc]initWithFrame:CGRectMake((WIDE-90)/6+((WIDE-90)/3+30)*i,0,30,20)];
        NSArray*ary=[NSArray arrayWithObjects:@"好评",@"中评",@"差评", nil];
        pingJiaLabel.text=ary[i];
        pingJiaLabel.textAlignment=NSTextAlignmentCenter;
        pingJiaLabel.textColor=[UIColor blackColor];
        pingJiaLabel.font=[UIFont systemFontOfSize:15];
        [view1 addSubview:pingJiaLabel];
        
    }

    textView=[[UITextView alloc]initWithFrame:CGRectMake(5, 64+30+30, WIDE-10,100)];
    textView.layer.borderColor=RGB_COLOR(0x00c49f).CGColor;
    textView.layer.borderWidth=1;
    textView.layer.cornerRadius=6;
    textView.layer.masksToBounds=YES;
    
    [self.view addSubview:textView];
    UIButton*bigBut=[[UIButton alloc]initWithFrame:CGRectMake(10, 64+30+30+20+100, WIDE-20,40)];
    bigBut.backgroundColor=RGB_COLOR(0x00c49f);
    [bigBut setTitle:@"评价" forState:UIControlStateNormal];
    [bigBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    bigBut.layer.cornerRadius=5;
    bigBut.clipsToBounds=YES;
    [bigBut addTarget:self action:@selector(bigButClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:bigBut];
    
    // Do any additional setup after loading the view from its nib.
}
-(void)pingJiaBut:(UIButton*)sender
{

    _lastBtn.selected =NO;
    sender.selected = YES;
       _lastBtn = sender;
    _selectBut=sender.tag;
   
    
}
-(void)bigButClick
{
   
   [HttpsManager requestPingJiaCompletion:_orderId pingFen:[NSString stringWithFormat:@"%ld",_selectBut+1] coment:textView.text completion:^(int errcode, NSString *errmsg)
    {
        SHOW_ALERT(errmsg);
    }];
}
-(void)backBut

{
    WeiDianDingDanViewController*vc=[[WeiDianDingDanViewController alloc]init];
    vc.canShu=@"4";
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
